package practice;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main c = new Main();
        Main.Solution s = c.getSolution();
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        String line3 = sc.nextLine();
        String[] arr1 = line1.split(" ");
        int n = Integer.valueOf(arr1[0]);
        int m = Integer.valueOf(arr1[1]);
        String[] arr2 = line2.split(" ");
        String[] arr3 = line3.split(" ");
        int[] numarr2 = new int[n];
        for (int i = 0; i < n; i++) {
            numarr2[i] = Integer.valueOf(arr2[i]);
        }
        int[] numarr3 = new int[n];
        for (int i = 0; i < n; i++) {
            numarr3[i] = Integer.valueOf(arr3[i]);
        }
        int res = 0;
        int temp = 0;
        if (m == n) {
            for (int i = 0; i < m; i++) {
                res += numarr2[i];
            }
        } else {
            for (int i = 0; i < n - m; i++) {
                temp = s.countscore(numarr2, numarr3, i, m);
                if (temp > res) res = temp;
            }
        }

//            return 1;
        System.out.println(res);
//            return res;
    }

    Solution getSolution() {
        return new Solution();
    }

    class Solution {
        private int countscore(int[] arr1, int[] arr2, int index, int m) {
            int sum1 = 0, sum2 = 0, sum3 = 0;
            for (int i = 0; i < index; i++) {
                if (arr2[i] == 1) sum1 += arr1[i];
                else continue;
            }
            for (int i = index; i < index + m; i++) {
                sum2 += arr1[i];
            }
            for (int i = index + m; i < arr1.length; i++) {
                if (arr2[i] == 1) sum3 += arr1[i];
                else continue;
            }
            return sum1 + sum2 + sum3;
        }
    }

}
